package com.feicheng.controller.shop.wx.app.client;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.common.constant.Constant;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.controller.BaseController;
import com.feicheng.service.IFCheckCodeService;
import com.feicheng.service.IFStoreService;

@RestController("/wx/app/client/access")
@RequestMapping("/wx/app/client/access")
public class AccessController extends BaseController {
    @Autowired
    IFStoreService ifStoreService;

    @Autowired
    IFCheckCodeService ifCheckCodeService;

    @PostMapping("/cmd")
    public ResultInfo newCmd(String password, Integer accessId, Integer storeId, Integer CmdCode) {
        return ifCheckCodeService.newCmdToMapWX(password,  accessId, storeId, CmdCode);
    }
    @GetMapping("/access")
    public ResultInfo newCmd(Integer storeId) {
        ResultInfo storeRe = ifStoreService.getStoreInfo(storeId);
        Map<String, List> storeMap = (Map<String, List>) storeRe.get(Constant.RESULT.DATA);
        List accesses = storeMap.get(Constant.ENTITY.ACCESS.TABLE);
        return ResultInfo.success(accesses);
    }
}